package com.wenli.lt.controller;


import com.wenli.lt.entity.Classes;
import com.wenli.lt.entity.Grade;
import com.wenli.lt.service.IGradeService;
import com.wenli.lt.util.CommonResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lt
 * @since 2021-03-21
 */
@RestController
@Api(tags="年级接口")
@RequestMapping("grade")
public class GradeController {
    @Autowired
    IGradeService iGradeService;

    @PostMapping("/addGrade")
    @ApiOperation("新增年级")
    public CommonResponse addGrade(@RequestBody @ApiParam(name = "grade", value = "年级") Grade grade){
        if (iGradeService.addGrade(grade)){
            return new CommonResponse("新增成功");
        }else {
            return new CommonResponse(CommonResponse.ERROR_CODE,"已存在该年级!");
        }
    }

//    @GetMapping("/getGrade")
//    @ApiOperation("查询年级")
//    public CommonResponse getGrade(){
//            return new CommonResponse(iGradeService.getGrade());
//
//    }

}
